package cn.dida.service.impl;

import cn.dida.dao.LgsCustDao;
import cn.dida.model.LgsCust;
import cn.dida.model.Pageable;
import cn.dida.service.LgsCustService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by zhangzhiling on 2017/4/21.
 */
@Service
public class LgsCustServiceImpl implements LgsCustService{

    @Autowired
    private LgsCustDao lgsCustDao;

    @Override
    public Pageable<LgsCust> query(Integer companyId, String keyword, Integer state, int page) {
        return lgsCustDao.query(companyId,keyword,state,page);
    }

    @Override
    public Boolean insert(LgsCust lgsCust) {
        Integer id = lgsCustDao.insert(lgsCust);
        return true;
    }

    @Override
    public Boolean update(LgsCust lgsCust) {
        return lgsCustDao.update(lgsCust) ==1;
    }

    @Override
    public LgsCust getLgsCust(int id) {
        return lgsCustDao.getLgsCust(id);
    }

    /**
     * 验证客户编码是否已存在
     * @param companyId
     * @param custCode
     * @return
     */
    @Override
    public LgsCust testCode(Integer companyId, String custCode) {
        return lgsCustDao.testCode(companyId,custCode);
    }


    /**
     * 获取区域列表
     * @param companyId
     * @return
     */
    @Override
    public List<Map<String, Object>> getAreaList(Integer companyId) {
        return lgsCustDao.getAreaList(companyId);
    }

    /**************************** 进货网点 ****************************/
    @Override
    public Pageable<LgsCust> queryCustList(Integer companyId, String keyword, String custCode, String mobile, int page) {
        return lgsCustDao.queryCustList(companyId,keyword,custCode,mobile,page);
    }

    @Override
    public Pageable<Map<String,Object>> queryCustScanList(Integer companyId, Integer branchId, String product, String boxCode,
                                                          String scanTimeS, String scanTimeE, int page){
        return lgsCustDao.queryCustScanList(companyId,branchId,product,boxCode,scanTimeS,scanTimeE,page);
    }
}
